package org.example.controller;

import org.example.entity.Silver;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController

public class SliverController {
    private List<Silver> SliverList = new ArrayList<>();

    @GetMapping("/crt")
    public String createTable() {
        // 这里可以编写创建表格的逻辑
        return "Table created successfully!";
    }

    @GetMapping("/add")
    public String addSliver(@RequestParam float purity, @RequestParam float weight, @RequestParam String finish) {
        Silver silver=new Silver();
        silver.setPurity(purity);
        silver.setWeight(weight);
        silver.setFinish(finish);
        SliverList.add(silver);
        // 这里可以编写将记录添加到数据库表格的逻辑
        return "House added successfully!";
    }

    @GetMapping("/getAll")
    public List<Silver> getAllHouses() {
        // 这里可以编写从数据库中获取所有记录的逻辑
        return SliverList;
    }
}
